/**
 * Created by yumeng on 2017/11/17.
 */
define([
  './themes/lang/' + window.YUFP_SYS_CONFIG.language + '/pages/example/template/exampleForm.js'
], function (require, exports) {
  // page加载完成后调用ready方法
  exports.ready = function (hashCode, data, cite) {
    yufp.lookup.reg('NATIONALITY,YESNO');
    // 创建virtual model
    var vm = yufp.custom.vue({
      el: '#exampleForm',
      data: function () {
        var me = this;
        return {
          editFields: [{
            columnCount: 2,
            fields: [
              { field: 'title',
                label: this.$t('exampleForm.xxbt'),
                placeholder: this.$t('exampleForm.dgzf'),
                type: 'input',
                rules: [{ required: true, message: this.$t('exampleForm.qsrxxbt'), trigger: 'blur' },
                  { min: 5, max: 25, message: this.$t('exampleForm.cdzdgzf'), trigger: 'blur' }]
              },
              { field: 'type',
                label: this.$t('exampleForm.lx'),
                type: 'select',
                dataCode: 'NATIONALITY',
                rules: [{ required: true, message: this.$t('exampleForm.qxzlx'), trigger: 'blur' }]
              },
              { field: 'status', label: this.$t('exampleForm.zt'), type: 'select', dataCode: 'PUBLISH_STATUS' },
              { field: 'author', label: this.$t('exampleForm.zz'), type: 'input', placeholder: this.$t('exampleForm.bjrxm')},
              { field: 'telNumber', label: this.$t('exampleForm.lxdh'), type: 'input', placeholder: this.$t('exampleForm.bjrlxdh')},
              { field: 'time', label: this.$t('exampleForm.fbsj'), type: 'daterange', placeholder: this.$t('exampleForm.szzdfbsj')},
              { field: 'tags',
                label: this.$t('exampleForm.ssbq'),
                type: 'checkbox',
                dataCode: 'NATIONALITY',
                change: function (val) {
                  console.log(val);
                }},
              { field: 'isTop',
                label: this.$t('exampleForm.sfzd'),
                type: 'radio',
                dataCode: 'YESNO',
                change: function (val) {
                  console.log(val);
                }
              }
            ]
          }, {
            columnCount: 1,
            fields: [
              { field: 'remark', label: this.$t('exampleForm.nr'), placeholder: this.$t('exampleForm.gzfyn'), type: 'textarea', rows: 6 }
            ]
          }],
          buttons: [
            {label: this.$t('exampleForm.qx'),
              type: 'primary',
              icon: 'yx-undo2',
              click: function () {
              // do something
              }},
            {label: this.$t('exampleForm.bc'),
              type: 'primary',
              icon: 'check',
              op: 'submit',
              click: function (model, valid) {
                if (valid) {
                  me.$msgbox.alert(model, this.$t('exampleForm.ts'));
                // do something
                }
              }},
            {label: this.$t('exampleForm.zz'),
              type: 'primary',
              icon: 'yx-loop2',
              op: 'reset',
              click: function (model) {
              // do something
              }}
          ]
        };
      },
      methods: {

      }
    });
  };
  // 消息处理
  exports.onmessage = function (type, message) {

  };
  // page销毁时触发destroy方法
  exports.destroy = function (id, cite) {

  };
});
